
package com.compuvest.ajax;

// <editor-fold defaultstate="collapsed" desc="import">
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
// </editor-fold>

public class GetTip extends HttpServlet {

// <editor-fold defaultstate="collapsed" desc="init static strings">
    public static final String GSA =
        // gsa
        "{wd:'210px'," +
        "bg:'#d8d8f4'," +
        "txt:'GSA# GS-35F-0097M<hr/>"+
        "<p>GSA stands for General Services Administration, the landlord and general store for much of the federal government. " +
        "A GSA Schedule (contract) is a formal agreement between a company and a federal government. " +
        "Government agencies need the schedule number in order to place orders under the GSA schedule.</p>'}";

    public static final String DB =
        // db
        "{wd:'210px'," +
        "bg:'#d8d8f4'," +
        "txt:'D&B 93-203-6999<hr/>"+
        "<p>Unique nine-digit D&B D-U-N-S Number is assigned to each business. It is used as a \"tool for identifying, " +
        "organizing and consolidating information about businesses. Companies worldwide use it to link information about " +
        "suppliers, customers and trading partners, providing them a more complete picture of risks " +
        "and opportunities in their business relationships.\"</p>'}";
//    (<a href="http://www.dnb.com" style="text-decoration:none;color:blue;" target="_blank">www.dnb.com</a>).

    public static final String WARRANTY =
        // wty
        "{wd:'400px'," +
        "bg:'#d8d8f4'," +
        "txt:'Extended Warranty<hr/>" +
        "<p>&nbsp;&nbsp;&nbsp;Thank you for your interest in Compuvest.com Extended Warranty. " +
        "This extended warranty program is designed to provide you with additional coverage for manufacturer defects.<br/>" +
        "&nbsp;&nbsp;&nbsp;Such service, repair or adjustment of this equipment is assured the original purchaser only. " +
        "This warranty does not cover equipment which has been misused, tampered with, modified or damaged " +
        "as a result of accident, liquid, grit, impact or lack of proper care as indicated in the manual " +
        "of operations.</p><br/>When does the Extended Warranty Coverage start?<br/><br/>" +
        "<p>&nbsp;&nbsp;&nbsp;Your Extended Warranty begins the day after your manufacturer warranty (if any) ends " +
        "<b>(unless different warranty period is specified in item description)</b>, ensuring you seamless extended coverage.<br/>" +
        "&nbsp;&nbsp;&nbsp;To have your equipment serviced under your Extended Warranty, please be sure to include your " +
        "Invoice number and/or a copy of your invoice when you send in your equipment (prior RMA approval applies same as " +
        "regular RMA returns procedure). When sending product back under warranty, please follow all RMA returns " +
        "procedures (provided at time of your RMA submission).</p>'}";

    public static final String BANK =
        //bph
        "{wd:'210px'," +
        "bg:'#d8d8f4'," +
        "txt:'Bank Phone :<hr/>" +
        "<p>Bank phone number is the customer service number located on the back of your credit card." +
        "This information is not required, designed to help our processing department contact the " +
        "correct bank faster when needed.</p>'}";

    public static final String SIGNATURE =
        //sgn
        "{wd:'210px'," +
        "bg:'#d8d8f4'," +
        "txt:'Signature Required :<hr/>" +
        "<p>You can add extra protection for your shipment by adding signature required option. " +
        "Carriers such as USPS or UPS will NOT leave your shipment by the  door without your signature .</p>'}";

    public static final String PROMOTION =
        //spp
        "{wd:'210px'," +
        "bg:'#d8d8f4'," +
        "txt:'Special Price :<hr/>" +
        "<p>&nbsp;Compuvest has special promotions going on throughout the month with various products that are listed, " +
        "these products have set quantity with lower pricing.<br/>Once this promotional quantity sells out, product then can " +
        "only be purchased at regular price, no exceptions.<br/>" +
        "Please feel free to contact us with any questions you might have.</p>'}";

    public static final String AMAZON =
        //amzn
        "{wd:'400px'," +
        "bg:'#d8d8f4'," +
        "txt:'<div style=\"text-align:center;\">CompuVest.com is now connected with Amazon.com!<br/>" +
        "Free ground shipping on all orders paid by Amazon checkout!</div><hr/>" +
        "<p>We are proud to announce that we are teaming up with Amazon.com to make your \"check out\" " +
        "experience SIMPLE and CONVENIENT. So simple that when you check out through your " +
        "Amazon.com Account, you do not need to enter any personal information on our website. " +
        "Once you have your Compuvest.com shopping cart full and ready to check out, you will proceed " +
        "(click on) to familiar Amazon.com icon for all of your billing, shipping and payment " +
        "details. Your CompuVest.com order history will also be stored on your Amazon.com account for " +
        "your convenience.<br/> " +
        "You still can use your existing account with us or to create a new direct account \"Check out " +
        "by Amazon\" is just an additional option for your convenience where you also get your order shipped for free.</p>'}";
// </editor-fold>

// <editor-fold defaultstate="collapsed" desc="init()">

    @Override
    public void init(ServletConfig config) throws ServletException {
	super.init(config);

        System.out.println("GetTip init:");
    }
// </editor-fold>

// <editor-fold defaultstate="collapsed" desc="processRequest()">

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)  throws ServletException, IOException {

        String id = request.getParameter("id");

        String json = "";
        if(id != null) {
            if("".equals(id)) {
                json = "{wd:'100px',bg:'navy',txt:'No tip now'}";
            }
            else if("gsa".equals(id)) {
                json = GSA;
            }
            else if("db".equals(id)) {
                json = DB;
            }
            else if("spp".equals(id)) {
                json = PROMOTION;
            }
            else if("wty".equals(id)) {
                json = WARRANTY;
            }
            else if("sgn".equals(id)) {
                json = SIGNATURE;
            }
            else if("bph".equals(id)) {
                json = BANK;
            }
            else if("amzn".equals(id)) {
                json = AMAZON;
            }
        }

        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            out.print(json);
        }
        finally {
            out.close();
        }
    }
// </editor-fold>

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods.">
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        processRequest(request, response);
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        processRequest(request, response);
    }
    @Override
    public String getServletInfo() {
        return "GetTip";
    }
    @Override
    public void destroy() {
	System.out.println("GetTip Destroy:");
    }
// </editor-fold>

}
